package cn.skyquant.quant4j.api.quant;


import cn.skyquant.quant4j.api.enums.VType;
import cn.skyquant.quant4j.sdk.util.time.CalendarUtils;

import java.util.List;
import java.util.Objects;


public class VBar extends TimeBar {
    public final VType vType;
    public final int i;

    public VBar(TimeBar timeBar, VType vType, int i) {
        super(timeBar.open,timeBar.close,timeBar.high,timeBar.low,timeBar.volumn,timeBar.time);
        this.vType = vType;
        this.i = i;
    }

    public double getValue(){
        return vType == VType.V?low:high;
    }

    public String toString() {
            return String.format("%s %s %s",CalendarUtils.formatStandard(time), vType.name(), getValue());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        VBar vBar = (VBar) o;
        return vType == vBar.vType && time == vBar.time;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), time,vType);
    }


    public boolean contain(VBar other){
        return this.high > other.high && this.low < other.low;
    }
}
